// JScript source code

//contains calls to silverlight.js, example below loads Page.xaml
function createSilverlight()
{
	Silverlight.createObjectEx({
		source: "PuzzleDiamonds.xaml",
		parentElement: document.getElementById("SilverlightControlHost"),
		id: "SilverlightControl",
		properties: {
			width: "100%",
			height: "100%",
			version: "1.1",
			enableHtmlAccess: "true"
		},
		events: 
		{
            onLoad: OnLoaded
        }
	});
	   	  
	// Give the keyboard focus to the Silverlight control by default
    //document.body.onload = function() {
    //  var silverlightControl = document.getElementById('SilverlightControl');
    //  if (silverlightControl)
    //  {
    //    silverlightControl.focus();
    //    silverlightControl.Content.PuzzleDiamondsApp.CallbackToBrowser = onSilverlightCallback;
    //  }
    //  
    //  onSilverlightCallback();
    //  
    //  setTimeout("gameLoop()", 20);
    // }
}

function OnLoaded()
{
      var silverlightControl = document.getElementById('SilverlightControl');
      if (silverlightControl)
      {
        silverlightControl.focus();
        silverlightControl.Content.PuzzleDiamondsApp.CallbackToBrowser = onSilverlightCallback;
      }
      setTimeout("gameLoop()", 20);
}

function onSilverlightCallback(sender, args)
{  
    window.open("http://moriarty72.spaces.live.com");   
}

function gameLoop()
{
    var silverlightControl = document.getElementById('SilverlightControl');
    if (silverlightControl)
    {        
        silverlightControl.Content.PuzzleDiamondsApp.OnGameLoop();        
        setTimeout("gameLoop()", 20);
    }
}
